import React, { Component } from 'react'; /* eslint-disable eqeqeq */
import 'antd/dist/antd.less';
import Lighting from "../running/lighting/lighting";
import Map from "../running/map/map";
import Line from "../running/line/line";
import Sound from "../running/sound/sound";
import Data from "../running/data/data";
import Distribution from "../running/distribution/distribution";
import Wonderful from "../running/wonderful/wonderful";
import Socialize1 from "../running/socialize/socialize1/socialize1";
import Socialize2 from "../running/socialize/socialize2/socialize2";
import Socialize3 from "../running/socialize/socialize3/socialize3";
import Application from "../running/game/application/application";
import Create from "../running/game/create/create";
import Manage from "../running/game/manage/manage";
import Ad from "../running/ad/ad";

import DMX from "../Setting/setlighting/DMX/DMX";
import BLE from "../Setting/setlighting/BLE/BLE";
import ChangeSet from "../Setting/setlighting/changeSet/changeSet";
import Scene from "../Setting/scene/scene";

import Center from "../service/center/center";
import Rundata from "../service/data/data";
import Socialize11 from "../service/socialize/socialize1/socialize1";
import Socialize22 from "../service/socialize/socialize2/socialize2";
import Socialize33 from "../service/socialize/socialize3/socialize3";
import Wonderful1 from "../service/wonderful/wonderful";

import Camera from "../manage/camera/camera";
import Sensor from "../manage/sensor/sensor";
import Amps from "../manage/amps/amps";
import Online from "../manage/ble/online/online";
import Funct from "../manage/ble/function/function";


import Device from "../database/device/device";
import Statistics1 from "../database/statistics/statistics";
import Userwonderful from "../database/userwonderful/userwonderful";

import Lake from "../log/lake/lake";
import Restaurant from "../log/Restaurant/Restaurant";
import Loglake from "../log/loglake/loglake";

import Home from '../home/home';

import Statistics from "../database/statistics/statistics";
import { Layout, Button, Modal, message } from 'antd';
import { connect } from 'react-redux'
import { createDeletUserInfoAction } from '../../redux/action_craetors/login_action'
import { meshLog } from '../../config';
import './css/admin.less'
import PubSub from 'pubsub-js'
import NavLeft from './header/header'
import { Route, Routes, Navigate, Outlet } from 'react-router-dom'
import icon_account_logo from '../../static/menu/touxiang.png'
import tuichu from '../../static/menu/tuichu.png'

export let mqttdateCount = 0; //延迟时间
export let devisUnOnline = 0; //延迟时间
const { Content } = Layout;
const { confirm } = Modal;

class Admin extends Component {
  constructor(a) {
    super(a);
    this.state = {

    }

  }
  componentDidMount() {
    meshLog('this.props.userInfo', this.props.userInfo);
  }
  handleClick() {
    this.setState(prevStat => (
      {
        isToggleon: !prevStat.isToggleon,
        display: prevStat.isToggleon ? 'block' : 'none'
      }
    ));
  }
  //点击退出登录的回调函数
  logOut = () => {
    confirm({
      title: 'LOGOUT',
      content: 'Logging out will clear local data. Are you sure?',
      cancelText: 'Cancel',
      okText: 'Yes,Sure',
      onOk: () => {
        this.props.deletUser()
        PubSub.publish('zidongdingshi', '')
      },
      onCancel() { },
    });
    //退出的，调用redux
  }


  componentDidUpdate() {
  }

  render() {
    //要进行判断是否登录了，测试的
    const { isLogin } = this.props.userInfo

    if (!isLogin) {
      return <Navigate replace to="/login" />
    }
    else {
      return (
        <div className='baby' style={{ overflow: 'hidden' }}>
          <Layout className='admincss'>
            <Layout>
              <div className='siderless'  >
                {/* <img className='but' src={icon_drag_handle} onClick={this.handleClick} alt="" /> */}
                <span className='but' style={{ alignItems: 'center', alignContent: 'center' }}  >智慧跑管理平台</span>
              </div>
              <div className='headername' style={{ height: 50, position: 'fixed', zIndex: 9998 }} >
                <img className='headernameimg' src={icon_account_logo} alt='' />
                <span style={{ marginLeft: 5, color: 'white' }} >123456</span>
                <img className='logout' style={{ marginLeft: 10, }} onClick={this.logOut} src={tuichu} alt='' />

              </div>
              <div className="zuidaneirong" >
                <div className="daohang" >
                  <div style={{ width: 340, marginTop: 80 }}>
                    <NavLeft />
                  </div>
                </div>
                <div className="zuida">
                  <div className="you">
                    <div style={{ textAlign: 'center', marginTop: 10 }}>
                      <Content className='contentcss'>
                        <Routes>
                          <Route path="/" element={<div ><Home /></div>} />
                          <Route path="/running/lighting" element={<div ><Lighting /></div>} />
                          <Route path="/running/wonderful" element={<div><Wonderful /></div>} />
                          <Route path="/running/sound" element={<div><Sound /></div>} />
                          <Route path="/running/map" element={<div><Map /></div>} />
                          <Route path="/running/line" element={<div><Line /></div>} />
                          <Route path="/running/distribution" element={<div ><Distribution /></div>} />
                          <Route path="/running/socialize/socialize1" element={<div ><Socialize1 /></div>} />
                          <Route path="/running/socialize/socialize2" element={<div><Socialize2 /></div>} />
                          <Route path="/running/socialize/socialize3" element={<div><Socialize3 /></div>} />
                          <Route path="/running/data" element={<div><Data /></div>} />
                          <Route path="/running/game/application" element={<div ><Application /></div>} />
                          <Route path="/running/game/manage" element={<div><Manage /></div>} />
                          <Route path="/running/game/create" element={<div><Create /></div>} />
                          <Route path="/running/ad" element={<div><Ad /></div>} />

                          <Route path="/setting/setlighting/DMX" element={<div><DMX /></div>} />
                          <Route path="/setting/setlighting/ble" element={<div><BLE /></div>} />
                          <Route path="/setting/setlighting/changeSet" element={<div><ChangeSet /></div>} />
                          <Route path="/setting/scene" element={<div><Scene /></div>} />

                          <Route path="/service/center" element={<div><Center /></div>} />
                          <Route path="/service/rundata" element={<div><Rundata /></div>} />
                          <Route path="/service/socialize/socialize1" element={<div><Socialize11 /></div>} />
                          <Route path="/service/socialize/socialize2" element={<div><Socialize22 /></div>} />
                          <Route path="/service/socialize/socialize3" element={<div><Socialize33 /></div>} />
                          <Route path="/service/wonderful" element={<div><Wonderful1 /></div>} />

                          <Route path="/manage/ble/online" element={<div><Online /></div>} />
                          <Route path="/manage/ble/function" element={<div><Funct /></div>} />
                          <Route path="/manage/amps" element={<div><Amps /></div>} />
                          <Route path="/manage/camera" element={<div><Camera /></div>} />
                          <Route path="/manage/sensor" element={<div><Sensor /></div>} />

                          <Route path="/database/device" element={<div><Device /></div>} />
                          <Route path="/database/statistics" element={<div><Statistics1 /></div>} />
                          <Route path="/database/userwonderful" element={<div><Userwonderful /></div>} />

                          <Route path="/log/lake" element={<div><Lake /></div>} />
                          <Route path="/log/Restaurant" element={<div><Restaurant /></div>} />
                          <Route path="/log/loglake" element={<div><Loglake /></div>} />

                        </Routes>
                      </Content>
                    </div>
                  </div>
                </div>
              </div >
            </Layout>
          </Layout>

        </div >
      )
    }
  }
}
export default connect(
  state => ({ userInfo: state }),
  { deletUser: createDeletUserInfoAction }
)(Admin)
